package com.fhz.day006

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    var num = 0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


        val int = savedInstanceState?.getInt("num")
        if(int != null){
            tv.text = int.toString()
        }
        Log.i("start","start")
        btn.setOnClickListener {
            tv.text = num++.toString()
        }
    }


    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        outState.putInt("num",num)

    }

    override fun onDestroy() {
        super.onDestroy()
        Log.i("onDestroy","onDestroy")

    }
}
